<?php
/**
 * 单页面文章系统 分类
 * */
class InfoclassModel extends Model
{
    /**
     * 获取关联
     * */
    protected $_link = array(
    	array(
    		'mapping_type' => HAS_MANY,
    		'class_name' => 'Info',
    		'foreign_key' => 'cid',
    		'mapping_name' => 'Infos',
    		'mapping_fields' => 'iid,cid,info_order,title,created,updated',
    		'mapping_order' => 'info_order desc,iid desc',
    	)
    );

    /**
     * 设置验证
     * array(验证字段,验证规则,错误提示,验证条件,附加规则,验证时间)
     * */
    protected $_validate = array(
                                 array('name','require','分类名称为必须填写!'),
                                 array('name','checklen','长度不能大于60个字符',1,'function')
                                 );

    protected function checklen($name) {
        if(strlen($name) > 60) {
            return false;
        } else {
            return true;
        }
    }
	/**
	 * 创建时间自动
	 *
	 * @var unknown_type
	 */
    protected $autoCreateTimestamps = array('created');
	/**
	 * 修改时间自动
	 *
	 * @var unknown_type
	 */
    protected $autoUpdateTimestamps = array('updated');
    
}
?>
